package com.example.seh.square.custom;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.seh.R;
import com.example.seh.square.Post;
import com.example.seh.square.SquareAdapter;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.List;

public class ContentAdapter extends BaseAdapter {

    private Context context;
    private List<Post> lists;
    private int item;
    private static DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
    private static String timeStr = null;
    private Bitmap bitmap;

    public ContentAdapter(Context context, List<Post> lists, int item) {
        this.context = context;
        this.lists = lists;
        this.item = item;
    }

    @Override
    public int getCount() {
        if (lists != null) {
            return lists.size();
        }
        return 0;
    }

    @Override
    public Object getItem(int position) {
        if (lists != null) {
            return lists.get(position);
        }
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (null == convertView) {
            convertView = LayoutInflater.from(context).inflate(item, null);
            viewHolder = new ViewHolder();
            viewHolder.userPic = convertView.findViewById(R.id.detail_page_userLogo);
            viewHolder.userName = convertView.findViewById(R.id.detail_page_userName);
            viewHolder.time = convertView.findViewById(R.id.detail_page_time);
            viewHolder.content = convertView.findViewById(R.id.detail_page_story);
            viewHolder.pic1 = convertView.findViewById(R.id.detail_pic1);
            viewHolder.pic2 = convertView.findViewById(R.id.detail_pic2);
            viewHolder.pic3 = convertView.findViewById(R.id.detail_pic3);
            convertView.setTag(viewHolder);
        }else {
            viewHolder =(ViewHolder) convertView.getTag();
        }

        return null;
    }

    class ViewHolder {
        private ImageView userPic,pic1,pic2,pic3;
        private TextView userName,time,title,content;
    }
}
